package com.ys.nms.module.business.dal.mysql.devicesLog;

import java.util.*;

import com.ys.nms.framework.common.pojo.PageResult;
import com.ys.nms.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ys.nms.framework.mybatis.core.mapper.BaseMapperX;
import com.ys.nms.module.business.dal.dataobject.devicesLog.DevicesLogDO;
import org.apache.ibatis.annotations.Mapper;
import com.ys.nms.module.business.controller.admin.devicesLog.vo.*;

/**
 * 设备日志 Mapper
 *
 * @author zzy
 */
@Mapper
public interface DevicesLogMapper extends BaseMapperX<DevicesLogDO> {

    default PageResult<DevicesLogDO> selectPage(DevicesLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DevicesLogDO>()
                .eqIfPresent(DevicesLogDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(DevicesLogDO::getInserted, reqVO.getInserted())
                .eqIfPresent(DevicesLogDO::getStatus, reqVO.getStatus())
                .eqIfPresent(DevicesLogDO::getStatusReason, reqVO.getStatusReason())
                .betweenIfPresent(DevicesLogDO::getUptime, reqVO.getUptime())
                .betweenIfPresent(DevicesLogDO::getAgentUptime, reqVO.getAgentUptime())
                .eqIfPresent(DevicesLogDO::getLastPolled, reqVO.getLastPolled())
                .eqIfPresent(DevicesLogDO::getLastPollAttempted, reqVO.getLastPollAttempted())
                .eqIfPresent(DevicesLogDO::getLastPolledTimetaken, reqVO.getLastPolledTimetaken())
                .eqIfPresent(DevicesLogDO::getLastDiscoveredTimetaken, reqVO.getLastDiscoveredTimetaken())
                .eqIfPresent(DevicesLogDO::getLastDiscovered, reqVO.getLastDiscovered())
                .eqIfPresent(DevicesLogDO::getLastPing, reqVO.getLastPing())
                .eqIfPresent(DevicesLogDO::getLastPingTimetaken, reqVO.getLastPingTimetaken())
                .eqIfPresent(DevicesLogDO::getSnmpyes, reqVO.getSnmpyes())
                .orderByDesc(DevicesLogDO::getLogId));
    }

}